1 <?php
2  session_start();
3  
if(isset($_SESSION['user']))
4  {
5
6  }
7  
else{
8   echo
"<script>location.href='login.html'</script>";
9  }
10 ?>
11 <!doctype html>
12 <html>
13 <head>
14   <title>
15   Salesdetails
16   </title>
17 <style>
18   
19   body {
20   margin:
0;
21   font-family: Arial, Helvetica, sans-serif;
22   background: #
484848;
23 }
24 .topnav {
25   overflow: hidden;
26   background-color: rgba(
249, 105, 14, 1);
27   height: 70px;
28   border: 3px solid #e69500;
29 }
30
31 .topnav a {
32   
float: left;
33   color: #f2f2f2;
34   text-align: center;
35   padding: 14px 16px;
36   text-decoration: none;
37   font-size: 35px;
38   font-weight: bold;
39 }
40
41 .topnav-right {
42   
float: right;
43 }
44
45 fieldset { max-width: 450px;
46     background: #FAFAFA;
47     padding: 30px;
48     margin: 50px auto;
49     box-shadow: 1px 1px 25px rgba(
0, 0, 0, 0.35);
50     border-radius: 10px;
51     border: 6px solid rgba(
249, 105, 14, 1);
52
53
54 }
55
56 legend {
57   padding:
0.2em 0.5em;
58   border:2px solid rgba(
249, 105, 14, 1);
59   color:rgba(
249, 105, 14, 1);
60   font-size:
90%;
61   text-align:center;
62   width:250px;
63   }
64 </style>
65   </head>
66 <body>
67 <div
class="topnav">
68             <a
class="active" href="home.html"><img src="ic_add_pet.png"></a>
69             <a href=
"sales.php">Sales details</a>
70             <div
class="topnav-right">
71               <a href=
"logout.php">logout</a>
72             </div>
73           </div>
74 <form>
75 <button type=
"submit" formaction="sales.php" style="margin:15px;height: 30px;width: 100px;cursor:pointer;border-radius:15px;
76 border: 3px solid #e69500;background-color: rgba(
249, 105, 14, 1);color:#f2f2f2;font-size:15px;">back</button>
77 </form>
78 <form method=
"post" action="salesupdate.php">
79
80   <fieldset>
81   
82     <input type=
"text" id ="sd" name="id" placeholder="Enter the sales id" style="width:100%;height:30px;
83     border: 2px solid rgba(
249, 105, 14, 1); border-radius:5px;" required>
84    <br><br>
85    <input type=
"text" name="csid" placeholder="Enter the customer id" style="width:100%;height:30px;
86     border: 2px solid rgba(
249, 105, 14, 1);border-radius:5px; " required>
87   <br><br>
88    <input type=
"date" name="date" style="width:100%;height:30px;
89    border: 2px solid rgba(
249, 105, 14, 1);border-radius:5px;" required>
90   <br><br>
91   <input type=
"number" name="total" min="0" style="width:100%;height:30px;
92    border: 2px solid rgba(
249, 105, 14, 1);border-radius:5px;" required placeholder="Enter total amount">
93   <br><br>
94   <input type=
"submit" name="submit" value="update" style="width:100%;height:30px;border-radius:5px;
95   border: 2px solid rgba(
249, 105, 14, 1); cursor:pointer;background-color: rgba(249, 105, 14, 1)">&ensp;
96 </fieldset>
97
98 </form>
99 </body>
100 </html>
101 <?php

102 if
(isset($_POST["submit"]))
103 {
104   
// define variables and set to empty values
105 $servername =
"localhost";
106 $username =
"root";
107 $password =
"";
108 $dbname =
"Petshop_management";
109
110 // Create connection

111 $conn =
new mysqli($servername, $username, $password, $dbname);
112 // Check connection

113 if
($conn->connect_error) {
114     die(
"Connection failed: " . $conn->connect_error);
115 }

116 //echo
" CONNECTION ESTABLISHED \r\n";
117 //echo
" INSERTION IN PROCESS";
118 $id = $_POST[
"id"];
119   $cs_id = $_POST[
"csid"];
120   $date= $_POST[
"date"];
121   $total = $_POST[
"total"];
122  
123   $Query2=
"select count(*) from sales_details WHERE sd_id='$id'";
124   $Execute = mysqli_query($conn,$Query2);
125   $count = mysqli_fetch_row($Execute);
126   
if($count[0]==1)
127   {
128     $sql =
"UPDATE sales_details SET cs_id='$cs_id' ,date='$date' ,total='$total' where sd_id='$id'";
129     
if ($conn->multi_query($sql) == TRUE) {
130       echo
'<div>
131       <h1 style=
"color:#f2f2f2;font-size:20px; font-family: "Roboto", sans-serif;margin:auto;">'
132       .$id.
' updated successfully</h1>
133          </div>
';
134     }
else {
135         echo
"Error: " . $sql . "<br>" . $conn->error;
136     }
137   }
138   
else{
139     echo
'<div>
140     <h1 style=
"color:#f2f2f2;font-size:30px; font-family: "Roboto", sans-serif;margin:auto;">Given sales_id not found</h1>
141        </div>
';
142 }
143
144
145
146
147 $conn->close();
148 }
149
150
151 ?>


Gõ tìm kiếm nhanh...